package com.juc.threadPoolExecutor.threadPoolExecutor14;

import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

public class ArrayBlockingQueueTest2 {

	public static void main(String[] args) {
	
			//ArrayBlockingQueue 使用带参构造方法
			//max 值被参考
		    //单队列容量不够，有一个任务出现异常
			ArrayBlockingQueue array = new ArrayBlockingQueue(2);
			System.out.println(array.size());
			ThreadPoolExecutor executor = new ThreadPoolExecutor(2, 3, 5, TimeUnit.SECONDS, array);
			executor.execute(new MyRunnable());
			executor.execute(new MyRunnable());
			executor.execute(new MyRunnable());
			executor.execute(new MyRunnable());
			executor.execute(new MyRunnable());
			executor.execute(new MyRunnable());
			System.out.println(executor.getPoolSize() + "     " + array.size());
			//放入队列2个任务 执行3个任务
		    //有1个任务被拒绝
	}
}
